package hc.core;

import hc.core.util.StringUtil;

import java.util.Vector;

public class RootConfig {
	private static RootConfig rc;
	
	public static RootConfig getInstance(){
		if(rc == null){
			String msg = RootServerConnector.getRootConfig();
			if(msg != null){
				rc = new RootConfig(msg);
			}
		}
		return rc;
	}
	
	public static void setInstance(RootConfig rcfg){
		rc = rcfg;
	}
	
	public RootConfig(String msg) {
//		System.out.println(msg);
		String split = "###";
		v = StringUtil.split(msg, split);
	}

	public static final short p_ShowDonate = 0;//停止使用
	public static final short p_RelayDirectBFSize = 1;
	public static final short p_DefaultUDPSize = 2;
	public static final short p_SendBufferSize = 3;
	public static final short p_ReceiveBufferSize = 4;
	public static final short p_Color_On_Relay = 5;
	public static final short p_MS_On_Relay = 6;
	public static final short p_MIDP_VER = 7;
	public static final short p_ClientServerSendBufferSize = 8;
	public static final short p_RelayTryNum = 9;
	public static final short p_ScreenCapMinBlockSize = 10;
	public static final short p_RootDelNotAlive = 11;
	public static final short p_ShowDesingerToAll = 12;
	public static final short p_KeepAliveMS = 13;
	public static final short p_ShowDesinger = 14;
	public static final short p_RelayServerThreadPriority = 15;
	public static final short p_RootRelayServer = 16;
	public static final short p_RootRelayServerPort = 17;
	public static final short p_MIDP_START_TONE = 18;
	public static final short p_Discover_Stun_Server_Time_Out_MS = 19;
	public static final short p_MIDP_START_TONE_VOL_LEVEL = 20;
	public static final short p_Display_Install_Tip = 21;
	public static final short p_ServerSendBufferSize = 22;
	public static final short p_ServerReceiveBufferSize = 23;
	public static final short p_enableLineWatcher = 24;
	public static final short p_TrafficClass = 25;
	public static final short p_forceRelay = 26;
	public static final short p_udpSendSize = 27;
	public static final short p_udpReceiveSize = 28;
	public static final short p_Packet_Resend_MS = 29;
	public static final short p_Packet_Resend_MaxSize = 30;
	public static final short p_PacketResendMaxTimes = 31;//暂停使用
	public static final short p_PacketLossDeepMsgIDNum = 32;
	public static final short p_Packet_Resend_Expired_MS = 33;
	public static final short p_mobile_color_bit_install = 34;
	public static final short p_First_Reg_Tuto = 35;
	public static final short p_Sample_Ver = 36;

	//如果增加一个，请修改本值
	private Vector v = new Vector(38);
	
	public int getIntProperty(short propertyID) {
		return Integer.parseInt((String)v.elementAt(propertyID));
	}
	
	public boolean isTrue(short propertyID) {
		String obj = (String)v.elementAt(propertyID);
		if(obj == null){
			return false;
		}else{
			return obj.equals(IConstant.TRUE);
		}
	}

	public String getProperty(short propertyID) {
		return (String)v.elementAt(propertyID);
	}
	
	public void setPropertyNull(short propertyID){
		v.setElementAt(null, propertyID);
	}

	public void setProperty(short propertyID, Object value){
		v.setElementAt(value, propertyID);
	}
}
